
import { ecs } from "db://oops-framework/libs/ecs/ECS";
import { Scene } from "../Scene";
import { oops } from "db://oops-framework/core/Oops";
import { BattleEventTrigger } from "../../skill/bll/utils/BattleEventTrigger";
import { BattleType } from "../SceneEvent";
import { smc } from "../../../common/ecs/SingletonModuleComp";

/**
 * 回合开始
 */
@ecs.register('RoundStart')
export class RoundStartComp extends ecs.Comp {
    reset() {

    }
}

export class RoundStartSystem extends ecs.ComblockSystem implements ecs.IEntityEnterSystem {
    filter(): ecs.IMatcher {
        return ecs.allOf(RoundStartComp);
    }

    entityEnter(e: Scene): void {
        e.sortBySpd();
        oops.log.trace(`<<第${e.MapModelRole.round}回合>>开始`);

        // 触发技能战报
        BattleEventTrigger.onRoundStart(BattleType.Scene);
        smc.scene.play(() => {
            //战斗
            e.autoStart();
        });

         // 回合结束（动画播放完后，对接回合开始）

         e.remove(RoundStartComp);
    }
}